package com.imooc.dao;

import java.io.IOException;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.imooc.bean.Command;
import com.imooc.bean.Message;
import com.imooc.db.DBAccess;

/**
* Created By lijiliang on 2018年7月25日 上午11:45:35
*/
public class CommandDao {
	/**
	 * 根据查询条件得到指令列表
	 * @param name
	 * @param description
	 * @return
	 */
	public List<Command> queryCommandList(String name,String description) {
		DBAccess dbAccess=new DBAccess();
		List<Command> commandList = null;
		Command command=new Command();
		command.setName(name);
		command.setDescription(description);
		SqlSession sqlSession=null;
		try {
			sqlSession=dbAccess.getSqlSession();
			//通过sqlSession执行sql语句
			commandList=sqlSession.selectList("Command.queryCommandList",command);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			if(sqlSession!=null) {
				sqlSession.close();				
			}

		}
		
		return commandList;
	}
}
